"""斐波那契函数 即 f(n)=f(n-1)+f(n-2)"""


def fibs(n):
    if n < 1:
        return 0
    elif n == 1 or n == 2:
        return n
    else:
        result = 1
        pre = 1
        temp = 0
        for i in range(n-2):
            temp = result
            result = result + pre
            pre = temp

        return result


def fibArr(n):
    result = [1, 1]
    for i in range(n - 2):
        result.append(result[-2] + result[-1])
    return result


if __name__ == '__main__':
    print(fibs(50))
    print(fibArr(50))
